<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>看数组 观察变化找规律</title>
</head>

<body>
    <!-- 一、看数组 观察变化找规律
初始 ['a','b','c','d','e'] 
第一次 ['d','e','a','b','c']
第二次 ['b','c','d','e','a']
第三次 ['e','a','b','c','d']
...
请问第五次 第十五次数组是如何?-->
    <script>
        var arr = new Array(5);
        arr = ['a', 'b', 'c', 'd', 'e'];
        var addIndex = 0;
        for (var i = 1; i < 16; i++) {
            addIndex += 2;
        }
        console.log(addIndex);
        for (var j = 0; j < arr.length; j++) {
            var finalIndex = j + addIndex
            for (var q = 1; finalIndex > 4; q++) {
                finalIndex -= 5;
            }

            arr[finalIndex] = arr[j];
        }
        console.log(arr);



        var arr2 =  ['a', 'b', 'c', 'd', 'e'];
        len = arr2.length;
        var resultArr = [];
        for (var j = 1;j <= 16;j++) {
            resultArr = [];
            for (var i = 0;i< len;i++){
                resultArr[(i + 2) % len] = arr2[i];
            }
            arr2 = resultArr;
            console.log(resultArr + '第' + j + '次');
        }
    </script>
</body>

</html>